﻿<%@ Page Title="AGR: Country Admin" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Country.aspx.cs" Inherits="AGR.Web.Pages.Administration.FormInformation" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="RightContent" runat="server">
</asp:Content>

<asp:Content ID="Content4" ContentPlaceHolderID="MainContent" runat="server">
    
    <h3>Country Administration</h3>
    <hr />

    <asp:UpdatePanel ID="CountryUpdatePanel" runat="server">
    <ContentTemplate>

    <table>
        <tr>
            <td>
                <asp:Button ID="btnAdd" runat="server" Text="Add" CssClass="button" onclick="btnAdd_Click" />
                <asp:Button ID="btnDelete" runat="server" Text="Remove" CssClass="button" onclick="btnDelete_Click" />
            </td>
        </tr>
        <tr>
            <td>
                <asp:GridView ID="CountryGridView" runat="server" CssClass="table-grid" AlternatingRowStyle-CssClass="odd" FooterStyle-CssClass="table-grid-footer"
                EmptyDataRowStyle-CssClass="empty" EmptyDataText="No countries found." PagerStyle-CssClass="pager"
                DataKeyNames="CountryName"
                AutoGenerateColumns="False" onrowcommand="CountryGridView_OnRowCommand"
                onrowcancelingedit="CountryGridView_RowCancelingEdit" onrowediting="CountryGridView_RowEditing" onrowupdating="CountryGridView_RowUpdating" 
                onpageindexchanging="CountryGridView_PageIndexChanging"
                AllowPaging="True" PageSize="10">
                    <PagerSettings Mode="NumericFirstLast" Position="Bottom"/>
                    <Columns>
                        <asp:TemplateField HeaderText="Select" HeaderStyle-Width="40px" 
                         HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" FooterStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <asp:CheckBox ID="chkSelect" runat="server" CausesValidation="False"> </asp:CheckBox>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:CheckBox ID="chkSelect" runat="server" Enabled="false" CausesValidation="False"> </asp:CheckBox>
                            </EditItemTemplate>
                            <FooterTemplate>
                                    <strong>Add</strong>
                                </FooterTemplate>
                        </asp:TemplateField>

                        <asp:TemplateField HeaderText="Options" HeaderStyle-Width="90px" HeaderStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <asp:LinkButton ID="lnkCountryEdit" runat="server" CausesValidation="False" CommandName="Edit" Text="Edit" />
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:LinkButton ID="lnkCountryCancel" runat="server" CausesValidation="False"  CommandName="Cancel" Text="Cancel"></asp:LinkButton>
                                &nbsp;
                                <asp:LinkButton ID="lnkCountryUpdate" runat="server" CausesValidation="True" CommandName="Update" Text="Update"
                                    ValidationGroup="CountryUpdateValidationGroup"></asp:LinkButton>
                            </EditItemTemplate>
                            <FooterTemplate>
                                <asp:LinkButton ID="btnCountryCancel" runat="server" Text="Cancel" CausesValidation="false" UseSubmitBehavior="false" CommandName="CancelInsert" />
                                &nbsp;
                                <asp:LinkButton ID="btnCountryInsert" runat="server" Text="Save" UseSubmitBehavior="false" CommandName="Insert"
                                    ValidationGroup="CountrySaveValidationGroup" />
                            </FooterTemplate>
                        </asp:TemplateField>

                        <asp:TemplateField HeaderText="Code" HeaderStyle-Width="35px">
                            <ItemTemplate><%# Eval("CountryCode")%></ItemTemplate>
                            <EditItemTemplate>
                                <asp:TextBox ID="txtCountryCode" runat="server" Text='<%# Eval("CountryCode")%>' MaxLength="2" Width="20px"></asp:TextBox>
                                <asp:RequiredFieldValidator ControlToValidate="txtCountryCode" ID="CountryCodeValidator" runat="server" ErrorMessage=" * "
                                    Display="Dynamic" CssClass="ClassValidator" ValidationGroup="CountryUpdateValidationGroup" ></asp:RequiredFieldValidator>
                            </EditItemTemplate>
                            <FooterTemplate>
                                <asp:TextBox ID="txtCountryCode" runat="server" Width="20px" MaxLength="2"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="CountryCodeValidator" runat="server" ErrorMessage=" * " Display="Dynamic" CssClass="ClassValidator"
                                    ControlToValidate="txtCountryCode" ValidationGroup="CountrySaveValidationGroup"></asp:RequiredFieldValidator>
                            </FooterTemplate>
                        </asp:TemplateField>

                        <asp:TemplateField HeaderText="Country" HeaderStyle-Width="110px">
                            <ItemTemplate><%# Eval("CountryName")%></ItemTemplate>
                            <EditItemTemplate>
                                <asp:TextBox ID="txtCountryName" runat="server" Text='<%# Eval("CountryName")%>' Width="100px" Enabled="false"></asp:TextBox>
                                <asp:RequiredFieldValidator ControlToValidate="txtCountryName" ID="CountryNameValidator" runat="server" ErrorMessage=" * " 
                                    Display="Dynamic" CssClass="ClassValidator" ValidationGroup="CountryUpdateValidationGroup" ></asp:RequiredFieldValidator>
                            </EditItemTemplate>
                            <FooterTemplate>
                                <asp:TextBox ID="txtCountryName" runat="server" Width="100px"></asp:TextBox>
                                <asp:RequiredFieldValidator ControlToValidate="txtCountryName" ID="CountryNameValidator" runat="server" ErrorMessage=" * " 
                                    Display="Dynamic" CssClass="ClassValidator"  ValidationGroup="CountrySaveValidationGroup" ></asp:RequiredFieldValidator>
                            </FooterTemplate>
                        </asp:TemplateField>

                        <asp:TemplateField HeaderText="Description" HeaderStyle-Width="140px">
                            <ItemTemplate><%# Eval("CountryLong")%></ItemTemplate>
                            <EditItemTemplate>
                                <asp:TextBox ID="txtCountryLong" runat="server" Text='<%# Eval("CountryLong")%>' Width="130px"></asp:TextBox>
                                <asp:RequiredFieldValidator ControlToValidate="txtCountryLong" ID="CountryLongValidator" runat="server" ErrorMessage=" * " 
                                    Display="Dynamic" CssClass="ClassValidator" ValidationGroup="CountryUpdateValidationGroup" ></asp:RequiredFieldValidator>
                            </EditItemTemplate>
                            <FooterTemplate>
                                <asp:TextBox ID="txtCountryLong" runat="server" Width="130px"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="CountryLongValidator" runat="server" ErrorMessage=" * " Display="Dynamic" CssClass="ClassValidator"
                                    ControlToValidate="txtCountryLong"  ValidationGroup="CountrySaveValidationGroup"></asp:RequiredFieldValidator>
                            </FooterTemplate>
                        </asp:TemplateField>

                        <asp:TemplateField HeaderText="Nationality" HeaderStyle-Width="115px">
                            <ItemTemplate><%# Eval("Nationality")%></ItemTemplate>
                            <EditItemTemplate>
                                <asp:TextBox ID="txtNationality" runat="server" Text='<%# Eval("Nationality")%>' Width="105px"></asp:TextBox>
                                <asp:RequiredFieldValidator ControlToValidate="txtNationality" ID="NationalityValidator" runat="server" ErrorMessage=" * " 
                                    Display="Dynamic" CssClass="ClassValidator" ValidationGroup="CountryUpdateValidationGroup" ></asp:RequiredFieldValidator>
                            </EditItemTemplate>
                            <FooterTemplate>
                                <asp:TextBox ID="txtNationality" runat="server" Width="110px"></asp:TextBox>
                                <asp:RequiredFieldValidator ControlToValidate="txtNationality" ID="NationalityValidator" runat="server" ErrorMessage=" * " 
                                    Display="Dynamic" CssClass="ClassValidator" ValidationGroup="CountrySaveValidationGroup" ></asp:RequiredFieldValidator>
                            </FooterTemplate>
                        </asp:TemplateField>

                        <asp:TemplateField HeaderText="Displayed" HeaderStyle-Width="50px" FooterStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <asp:CheckBox ID="chkDisplayed" runat="server" Enabled="false" 
                                    Checked='<%# (Convert.ToInt32(Eval("Displayed")) == 1) ? true : false%>' CausesValidation="False"></asp:CheckBox>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:CheckBox ID="chkDisplayed" runat="server" Enabled="true"
                                    Checked='<%# (Convert.ToInt32(Eval("Displayed")) == 1) ? true : false%>' CausesValidation="False"></asp:CheckBox>
                            </EditItemTemplate>
                            <FooterTemplate>
                                <asp:CheckBox ID="chkDisplayed" runat="server" CausesValidation="False" />
                            </FooterTemplate>
                            <ItemStyle HorizontalAlign="Center" />
                            <FooterStyle HorizontalAlign="Center" />
                        </asp:TemplateField>

                        <asp:BoundField DataField="DateCreated" HeaderText="Date Created" HeaderStyle-Width="120px" ReadOnly="true"/>
                        <asp:BoundField DataField="UserCreated" HeaderText="User Created" HeaderStyle-Width="85px" ReadOnly="true" />
                        <asp:BoundField DataField="DateModified" HeaderText="Date Modified" HeaderStyle-Width="120px" ReadOnly="true"/>
                        <asp:BoundField DataField="UserModified" HeaderText="User Modified" HeaderStyle-Width="85px" ReadOnly="true" />
                    </Columns>
                    <PagerStyle HorizontalAlign="Right" Wrap="False" />
                </asp:GridView>
            </td>
        </tr>
    </table>

    </ContentTemplate>
    </asp:UpdatePanel>

    <asp:UpdateProgress ID="CountryUpdateProgress" runat="server" AssociatedUpdatePanelID="CountryUpdatePanel">
    <ProgressTemplate>
        <div class="modalpopup">
            <div class="loadingpopup">
                <div class="center">
                    <img src="<%=ResolveUrl("~/Content/Images/Shared/spinner.gif") %>" alt="" height="50" width="50" />
                </div>
                <div class="center">
                     Please wait...
                </div>
            </div>
        </div>
    </ProgressTemplate>
    </asp:UpdateProgress>

</asp:Content>
